<?php
set_time_limit(0);
include '../../common.inc.php';
$hd = new ImportLoop();
$hd->setSource('mysql:host=localhost;dbname=test', 'root', 'root');
$hd->setAim('mysql:host=localhost;dbname=ixdcw_v12', 'root', 'root');
$hd->setSourceInfo('sheet1', 'id', '');
$params = array(
	'maxid'     => isset($_GET['maxid']) ? $_GET['maxid'] : 0,
	'id'        => isset($_GET['id']) && !empty($_GET['id']) ? $_GET['id'] : 0,
	'startTime' => isset($_GET['startTime']) ? $_GET['startTime'] : time(),
	'limit'     => 1,
	'interval'  => 1,
	'debug'     => isset($_GET['debug']) ? $_GET['debug'] : 'xddl',
);
$hd->initParams($params);

$result = $hd->getDbSource()->query('select * from ' . $hd->getSourceTable() . ' where id>' . $hd->getParam('id') . ' and ishandle=0 order by id ASC limit ' . $hd->getParam('limit'));
$rs     = $result->fetchAll();

$aimFolder = 'E:\outprint';

if (!$rs) {
	$hd->end();
} else {
	foreach ($rs as $k => $v) {
		$sql = Sql::update($hd->getSourceTable(), "ishandle=1", "id={$v['id']}");
		$hd->getDbSource()->query($sql);
		$aimName=$aimFolder.$v['folder'];
		var_dump($aimName);
		if (!file_exists($aimName)) {
			var_dump(mkdir(Str::convert($aimName, 'utf-8', 'gbk'), 0777, true));
		}
	}
}
var_dump($hd->getParams());
echo $hd->start($hd->getParams());